import React, { Component } from "react";
import { Card, Input, Select, Form } from "antd";

const renderText = userType => {
  if (userType === 10) {
    return "民警";
  }
  if (userType === 15) {
    return "现役";
  }
  if (userType === 20) {
    return "辅警";
  }
  if (userType === 25) {
    return "在编工勤";
  }
  return "外部人员";
};

const renderStation = userPartType => {
  if (userPartType === 10) {
    return "兼职";
  }

  if (userPartType === 20) {
    return "挂职";
  }
  if (userPartType === 25) {
    return "返聘（留用）";
  }
  if (userPartType === 30) {
    return "在职";
  }
  return userPartType;
};

@Form.create({
  mapPropsToFields: props => ({
    name: Form.createFormField({
      value: props.data.userName
    }),
    gender: Form.createFormField({
      value: props.data.userSex === 10 ? "男" : "女"
    }),
    idCard: Form.createFormField({
      value: props.data.userPoliceId
    }),
    idType: Form.createFormField({
      value: renderText(props.data.userType)
    }),
    station: Form.createFormField({
      value: renderStation(props.data.userPartType)
    }),
    organization: Form.createFormField({
      value: props.data.orgName
    })
  })
})
class EditBasic extends Component {
  render() {
    const { getFieldDecorator } = this.props.form;

    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    };

    return (
      <Card title="基本信息">
        <Form {...formItemLayout} onSubmit={this.handleSubmit}>
          <Form.Item label=" 姓名：">
            {getFieldDecorator("name", {
              rules: [
                {
                  message: "The input is not valid E-mail!"
                },
                {
                  required: true,
                  message: "Please input your E-mail!"
                }
              ]
            })(
              <Input
                style={{ width: 466, marginLeft: 8 }}
                placeholder="请输入姓名"
                disabled
                // value={this.state.managerName}
              />
            )}
          </Form.Item>

          <Form.Item label=" 性别：">
            {getFieldDecorator("gender", {
              rules: [
                {
                  required: true,
                  message: "Please input your nickname!",
                  whitespace: true
                }
              ]
            })(
              <Select
                showSearch
                style={{ width: 466, marginLeft: 8 }}
                placeholder="请选择性别"
                disabled
              />
            )}
          </Form.Item>
          {/* <Form.Item label=" 警号：">
            {getFieldDecorator("idCard", {
              rules: [
                {
                  required: true,
                  message: "请输入警号",
                  whitespace: true
                }
              ]
            })(
              <Input
                style={{ width: 466, marginLeft: 8 }}
                placeholder=" 请输入警号"
                disabled
                // value={this.state.managerName}
              />
            )}
          </Form.Item>
          <Form.Item label=" 身份类型：">
            {getFieldDecorator("idType", {
              rules: [
                {
                  required: true,
                  message: "请选择身份类型",
                  whitespace: true
                }
              ]
            })(
              <Select
                showSearch
                style={{ width: 466, marginLeft: 8 }}
                placeholder="请选择身份类型"
                disabled
              />
            )}
          </Form.Item> */}
          <Form.Item label=" 岗位情况：">
            {getFieldDecorator("station", {
              rules: [
                {
                  required: true,
                  message: "请选择岗位",
                  whitespace: true
                }
              ]
            })(
              <Select
                showSearch
                style={{ width: 466, marginLeft: 8 }}
                placeholder="请选择岗位"
                disabled
              />
            )}
          </Form.Item>
          <Form.Item label=" 所属机构：">
            {getFieldDecorator("organization", {
              rules: [
                {
                  required: true,
                  message: "请选择所属机构!",
                  whitespace: true
                }
              ]
            })(
              <Select
                showSearch
                style={{ width: 466, marginLeft: 8 }}
                placeholder="请选择所属机构"
                disabled
                // onChange={onChange}
              />
            )}
          </Form.Item>
        </Form>
      </Card>
    );
  }
}

export default EditBasic;
